<?php

echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>


<title>W-Programming Online Judge (WPOJ)</title>
<link href="Images/style.css" rel="stylesheet" type="text/css" id="theme">
<style type="text/css">
<!--
.maintable {width: 755px;} 
-->
</style>

</head><body>
<center>
<table class="maintable" id="maintable" cellpadding="10" cellspacing="0">
<tbody><tr>
    <td colspan="2" class="header">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr>
		<td class="headercenter">
			<h1><img alt="W-Programming Online Judge" title="W-Programming Online Judge" src="Images/wpoj.png" style="margin-top: -4px; margin-bottom: -4px;" border="0"></h1>
	</td></tr>
	</tbody></table>
    </td>
</tr>
<tr>
<td class="menu" valign="top" width="92">
<div class="menucmd">

';

function echo_unreg(){
	echo'
		<a href="/login.php">login</a><br>
		<a href="/register.php">register</a><br><br>
	';
}
function encrypt($arg)
{
	$poz=0;
	for ($i = 0; $arg[$i]; ++$i){
		$a = ord($arg[$i]);
		$b = ord('a');
		$c = $a - $b;
		if ($c < 10){
			$encr[$poz]=$c;
			$poz++;
		}
		else{
			$encr[$poz]=$c % 10;
			$poz++;
			$encr[$poz]=floor($c / 10);
			$poz++;
		}
	}
		//$arg[$i]+=$i;
	for ($i = 0; $i < $poz; ++$i){
		$ret[$i] = chr(ord('0') + $encr[$i]);
	//	echo '('.$encr[$i]." ".$ret[$i].') ';
	}
	//echo ' ';
	$ret[$poz] = 0;
	return implode("",$ret);
}
function no_user(&$username){
	echo '<h1> Username does not exist </h1>';
	echo_log();
	$username=false;
	return false;
}
$WPOJ_Is_Logged = 0;
if ($_COOKIE["user"] && $_COOKIE["password"]){
	mysql_connect("localhost", "root", "apache") or die(mysql_error());
	mysql_select_db("jobs") or die(mysql_error());
	$username=true;
	//echo $_COOKIE["user"].$_COOKIE["password"];
	//echo "SELECT * FROM users where user = '".$_COOKIE["user"]."'";
	$result = mysql_query("SELECT * FROM users where user = '".$_COOKIE["user"]."'") or die(mysql_error()); 
	$row = mysql_fetch_array( $result ) or no_user($username);
	if ($username == true){
		if ($_COOKIE["password"]){
			$encryptpass = $_COOKIE["password"];
			if ($encryptpass == $row['password']){
				echo '<a href="/logout.php">Log Out</a><br>';
				$WPOJ_Is_Logged = 1;
				echo $row['user'].'<br><hr>';
				if ($row['rights'] > 0){
					if ($row['rights'] == 2){
						// pun ce apare la admini
						# forum admin
						echo '<a href="/reeval.php">reevaluate submissions</a><br>';
						echo '<a href="/forum/adm">forum admin</a><br>';
						echo '<a href="/addcontest.php">add contest</a><br><hr>';
					}
					echo '<a href="/addproblem.php">add problem</a><br>';
					echo '<a href="/uploadfiles.php">upload files</a><br>';
					echo '<a href="/myproblemlist.php">problem list</a><br><hr>';					
					// pun ce apare la admini + helperi
				}
				echo '<a href="/myaccount.php">my account</a><br>';
				// pun ce apare la toti
				echo '<br>';
			}
			else
				echo_unreg();
		}
		else
			echo_unreg();
	}
	else
		echo_unreg();
}
else
	echo_unreg();
echo '
	<a href="/status.php">status</a><br>
	<a href="/submit.php">submit</a><br>
	<a href="/problems.php">problems</a><br><br>
	<a href="/">news</a><br>
	<a href="/contests.php">contests</a><br>
	<a href="/ranks.php">ranks</a><br><br>
	<a href="/forum">forum</a><br>
	<a href="/help.php">help</a><br><hr></div><div class="time">
Server time:
</div>
<div class="time">';
echo date("Y-m-d");
echo '<br><b>';
echo date("H : m : s");
echo '</b>
</div>

</td><td class="content" width="99%">
<p align="justify">';

if ($WPOJ_Is_Logged == 1)
	echo '<h1>You must logout to continue!</h1>';
else{
	echo'
	<br>
	<h1 style="margin-bottom: 18px; text-align: left;"> Register </h1>
	<body style="text-align: left;"> 
	If you are registered, you can login <a href="/login.php">here</a>. If you forgot your password, you cand reset it <a href="/	resetpass.php">here.</a><br>
	</body>
	<form name="register" action="/register.php" method="post" style="margin-bottom: 18px; text-align: left" class="smallgrey"> 
		Username: <br><input name="reg_user" style="width: 285px;" class="form" type="text"><br>
		Password: <br><input name="reg_password" style="width: 285px;" class="form" type="password"><br>
		Retype Password: <br><input name="reg_repassword" style="width: 285px;" class="form" type="password"><br>
		Email: <br><input name="reg_email" style="width: 285px;" class="form" type="text"><br>
Country:<br>
<select name="reg_country" style="width: 285px;">
<option value="0">Select a country</option>
<option value="1">AFGHANISTAN</option>
<option value="2">ALBANIA</option>
<option value="3">ALGERIA</option>
<option value="4">AMERICAN SAMOA</option>
<option value="5">ANDORRA</option>
<option value="6">ANGOLA</option>
<option value="7">ANGUILLA</option>
<option value="8">ANTARCTICA</option>
<option value="9">ANTIGUA AND BARBUDA</option>
<option value="10">ARGENTINA</option>
<option value="11">ARMENIA</option>
<option value="12">ARUBA</option>
<option value="13">AUSTRALIA</option>
<option value="14">AUSTRIA</option>
<option value="15">AZERBAIJAN</option>
<option value="16">BAHAMAS</option>
<option value="17">BAHRAIN</option>
<option value="18">BANGLADESH</option>
<option value="19">BARBADOS</option>
<option value="20">BELARUS</option>
<option value="21">BELGIUM</option>
<option value="22">BELIZE</option>
<option value="23">BENIN</option>
<option value="24">BERMUDA</option>
<option value="25">BHUTAN</option>
<option value="26">BOLIVIA</option>
<option value="27">BOSNIA AND HERZEGOVINA</option>
<option value="28">BOTSWANA</option>
<option value="29">BOUVET ISLAND</option>
<option value="30">BRAZIL</option>
<option value="31">BRITISH INDIAN OCEAN TERRITORY</option>
<option value="32">BRUNEI DARUSSALAM</option>
<option value="33">BULGARIA</option>
<option value="34">BURKINA FASO</option>
<option value="35">BURUNDI</option>
<option value="36">CAMBODIA</option>
<option value="37">CAMEROON</option>
<option value="38">CANADA</option>
<option value="39">CAPE VERDE</option>
<option value="40">CAYMAN ISLANDS</option>
<option value="41">CENTRAL AFRICAN REPUBLIC</option>
<option value="42">CHAD</option>
<option value="43">CHILE</option>
<option value="44">CHINA</option>
<option value="45">CHRISTMAS ISLAND</option>
<option value="46">COCOS (KEELING) ISLANDS</option>
<option value="47">COLOMBIA</option>
<option value="48">COMOROS</option>
<option value="49">CONGO</option>
<option value="50">CONGO, THE DEMOCRATIC REPUBLIC OF THE</option>
<option value="51">COOK ISLANDS</option>
<option value="52">COSTA RICA</option>
<option value="53">CÔTE D\'IVOIRE</option>
<option value="54">CROATIA</option>
<option value="55">CUBA</option>
<option value="56">CYPRUS</option>
<option value="57">CZECH REPUBLIC</option>
<option value="58">DENMARK</option>
<option value="59">DJIBOUTI</option>
<option value="60">DOMINICA</option>
<option value="61">DOMINICAN REPUBLIC</option>
<option value="62">ECUADOR</option>
<option value="63">EGYPT</option>
<option value="64">EL SALVADOR</option>
<option value="65">EQUATORIAL GUINEA</option>
<option value="66">ERITREA</option>
<option value="67">ESTONIA</option>
<option value="68">ETHIOPIA</option>
<option value="69">FALKLAND ISLANDS (MALVINAS)</option>
<option value="70">FAROE ISLANDS</option>
<option value="71">FIJI</option>
<option value="72">FINLAND</option>
<option value="73">FRANCE</option>
<option value="74">FRENCH GUIANA</option>
<option value="75">FRENCH POLYNESIA</option>
<option value="76">FRENCH SOUTHERN TERRITORIES</option>
<option value="77">GABON</option>
<option value="78">GAMBIA</option>
<option value="79">GEORGIA</option>
<option value="80">GERMANY</option>
<option value="81">GHANA</option>
<option value="82">GIBRALTAR</option>
<option value="83">GREECE</option>
<option value="84">GREENLAND</option>
<option value="85">GRENADA</option>
<option value="86">GUADELOUPE</option>
<option value="87">GUAM</option>
<option value="88">GUATEMALA</option>
<option value="89">GUINEA</option>
<option value="90">GUINEA-BISSAU</option>
<option value="91">GUYANA</option>
<option value="92">HAITI</option>
<option value="93">HEARD ISLAND AND MCDONALD ISLANDS</option>
<option value="94">HOLY SEE (VATICAN CITY STATE)</option>
<option value="95">HONDURAS</option>
<option value="96">HONG KONG</option>
<option value="97">HUNGARY</option>
<option value="98">ICELAND</option>
<option value="99">INDIA</option>
<option value="100">INDONESIA</option>
<option value="101">IRAN, ISLAMIC REPUBLIC OF</option>
<option value="102">IRAQ</option>
<option value="103">IRELAND</option>
<option value="104">ISRAEL</option>
<option value="105">ITALY</option>
<option value="106">JAMAICA</option>
<option value="107">JAPAN</option>
<option value="108">JORDAN</option>
<option value="109">KAZAKHSTAN</option>
<option value="110">KENYA</option>
<option value="111">KIRIBATI</option>
<option value="112">KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF</option>
<option value="113">KOREA, REPUBLIC OF</option>
<option value="114">KUWAIT</option>
<option value="115">KYRGYZSTAN</option>
<option value="116">LAO PEOPLE\'S DEMOCRATIC REPUBLIC</option>
<option value="117">LATVIA</option>
<option value="118">LEBANON</option>
<option value="119">LESOTHO</option>
<option value="120">LIBERIA</option>
<option value="121">LIBYAN ARAB JAMAHIRIYA</option>
<option value="122">LIECHTENSTEIN</option>
<option value="123">LITHUANIA</option>
<option value="124">LUXEMBOURG</option>
<option value="125">MACAO</option>
<option value="126">MACEDONIA</option>
<option value="127">MADAGASCAR</option>
<option value="128">MALAWI</option>
<option value="129">MALAYSIA</option>
<option value="130">MALDIVES</option>
<option value="131">MALI</option>
<option value="132">MALTA</option>
<option value="133">MARSHALL ISLANDS</option>
<option value="134">MARTINIQUE</option>
<option value="135">MAURITANIA</option>
<option value="136">MAURITIUS</option>
<option value="137">MAYOTTE</option>
<option value="138">MEXICO</option>
<option value="139">MICRONESIA, FEDERATED STATES OF</option>
<option value="140">MOLDOVA, REPUBLIC OF</option>
<option value="141">MONACO</option>
<option value="142">MONGOLIA</option>
<option value="240">MONTENEGRO</option>
<option value="143">MONTSERRAT</option>
<option value="144">MOROCCO</option>
<option value="145">MOZAMBIQUE</option>
<option value="146">MYANMAR</option>
<option value="147">NAMIBIA</option>
<option value="148">NAURU</option>
<option value="149">NEPAL</option>
<option value="150">NETHERLANDS</option>
<option value="151">NETHERLANDS ANTILLES</option>
<option value="152">NEW CALEDONIA</option>
<option value="153">NEW ZEALAND</option>
<option value="154">NICARAGUA</option>
<option value="155">NIGER</option>
<option value="156">NIGERIA</option>
<option value="157">NIUE</option>
<option value="158">NORFOLK ISLAND</option>
<option value="159">NORTHERN MARIANA ISLANDS</option>
<option value="160">NORWAY</option>
<option value="161">OMAN</option>
<option value="162">PAKISTAN</option>
<option value="163">PALAU</option>
<option value="164">PALESTINIAN TERRITORY, OCCUPIED</option>
<option value="165">PANAMA</option>
<option value="166">PAPUA NEW GUINEA</option>
<option value="167">PARAGUAY</option>
<option value="168">PERU</option>
<option value="169">PHILIPPINES</option>
<option value="170">PITCAIRN</option>
<option value="171">POLAND</option>
<option value="172">PORTUGAL</option>
<option value="173">PUERTO RICO</option>
<option value="174">QATAR</option>
<option value="175">RÉUNION</option>
<option value="176">ROMANIA</option>
<option value="177">RUSSIAN FEDERATION</option>
<option value="178">RWANDA</option>
<option value="179">SAINT HELENA</option>
<option value="180">SAINT KITTS AND NEVIS</option>
<option value="181">SAINT LUCIA</option>
<option value="182">SAINT PIERRE AND MIQUELON</option>
<option value="183">SAINT VINCENT AND THE GRENADINES</option>
<option value="184">SAMOA</option>
<option value="185">SAN MARINO</option>
<option value="186">SAO TOME AND PRINCIPE</option>
<option value="187">SAUDI ARABIA</option>
<option value="188">SENEGAL</option>
<option value="189">SERBIA</option>
<option value="190">SEYCHELLES</option>
<option value="191">SIERRA LEONE</option>
<option value="192">SINGAPORE</option>
<option value="193">SLOVAKIA</option>
<option value="194">SLOVENIA</option>
<option value="195">SOLOMON ISLANDS</option>
<option value="196">SOMALIA</option>
<option value="197">SOUTH AFRICA</option>
<option value="198">SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS</option>
<option value="199">SPAIN</option>
<option value="200">SRI LANKA</option>
<option value="201">SUDAN</option>
<option value="202">SURINAME</option>
<option value="203">SVALBARD AND JAN MAYEN</option>
<option value="204">SWAZILAND</option>
<option value="205">SWEDEN</option>
<option value="206">SWITZERLAND</option>
<option value="207">SYRIAN ARAB REPUBLIC</option>
<option value="208">TAIWAN, PROVINCE OF CHINA</option>
<option value="209">TAJIKISTAN</option>
<option value="210">TANZANIA, UNITED REPUBLIC OF</option>
<option value="211">THAILAND</option>
<option value="212">TIMOR-LESTE</option>
<option value="213">TOGO</option>
<option value="214">TOKELAU</option>
<option value="215">TONGA</option>
<option value="216">TRINIDAD AND TOBAGO</option>
<option value="217">TUNISIA</option>
<option value="218">TURKEY</option>
<option value="219">TURKMENISTAN</option>
<option value="220">TURKS AND CAICOS ISLANDS</option>
<option value="221">TUVALU</option>
<option value="222">UGANDA</option>
<option value="223">UKRAINE</option>
<option value="224">UNITED ARAB EMIRATES</option>
<option value="225">UNITED KINGDOM</option>
<option value="226">UNITED STATES</option>
<option value="227">UNITED STATES MINOR OUTLYING ISLANDS</option>
<option value="228">URUGUAY</option>
<option value="229">UZBEKISTAN</option>
<option value="230">VANUATU</option>
<option value="231">VENEZUELA</option>
<option value="232">VIET NAM</option>
<option value="233">VIRGIN ISLANDS, BRITISH</option>
<option value="234">VIRGIN ISLANDS, U.S.</option>
<option value="235">WALLIS AND FUTUNA</option>
<option value="236">WESTERN SAHARA</option>
<option value="237">YEMEN</option>
<option value="238">ZAMBIA</option>
<option value="239">[CITIZEN OF THE WORLD]</option>
<option value="242">[UNLISTED COUNTRY]</option>
</select><br>
		City: <br><input name="reg_city" style="width: 285px;" class="form" type="text"><br>
		Institution: <br><input name="reg_inst" style="width: 285px;" class="form" type="text"><br>
		Motto / URL: <br><input name="reg_motto" style="width: 285px;" class="form" type="text"><br>
		I want to receive newsletter <input type="checkbox" name="reg_newsl" value="true"><br>
		
		<input name="submit" value="Register" class="button" style="width: 85px;" type="submit">
	</form>';
}
echo '
</p></td>
</tr>

<tr>
<td colspan="2" class="footer">

<script language="javascript" type="text/javascript">
<!--
function swapSheet(sheet, caller) {
    document.getElementById(\'theme\').href=sheet;
    document.cookie="css_0="+sheet+"; path=/;";
    caller.href="#bottom";
}

function setWidth(w, caller) {
    document.getElementById(\'maintable\').style.width=w;
    document.cookie="res="+w+"; path=/;";
    caller.href="#bottom";
}


</script>
        <table width="100%">
    <tbody><tr>
	<td class="cfooter" align="left" width="10%">
		<a href="/info.php">About WPOJ</a>
	</td>
	<td class="cfooter" align="center">
	    page size:
	    <a href="/?rsl=755px" onclick="setWidth(\'755px\', this)">800x600</a>
	    <a href="/?rsl=980px" onclick="setWidth(\'980px\', this)">1024x768</a>
	    <a href="/?rsl=100%" onclick="setWidth(\'100%\', this)">Full</a>
	    &nbsp;&nbsp;
	</td>
    </tr>
    </tbody></table>
    </td></tr></tbody></table>
</center>
<div style="font-size: 10px; margin-top: 4px; color: rgb(85, 80, 95);"><center>
<a href="http://www.wpoj.ro/" style="color: black;">WPOJ</a>
System &#169; 2008-2009
<a href="toni" style="color: black;">Toni Pripoae</a>.  All Rights Reserved.</center></div>

</body></html>';

?>
